/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-09-04
 * Time: 12:33
 */
//class MyThread extends Thread{
//    @Override
//    public void run() {
//        System.out.println("hello thread");
//        try {
//            Thread.sleep(1_000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//    }
//}
//// 演示多线程的基本创建方式.
//public class Demo1 {
//    public static void main(String[] args) {
//        MyThread t = new MyThread();
//        t.start();
//
//        while (true){
//            System.out.println("hello main");
//            try {
//                Thread.sleep(1_000);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
//        }
//    }
//}
class MyThread extends Thread {
    @Override
    public void run() {
        while (true) {
            System.out.println("hello thread!");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

// 演示多线程的基本创建方式.
public class Demo1 {
    public static void main(String[] args) {
        MyThread t = new MyThread();
        t.start();

        while (true) {
            System.out.println("hello main");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}